#ifndef PROCESS_H
#define PROCESS_H

using namespace std;

struct ProcessReturn {
  int ret;
  int start_time;
  int cycles_completed;

  union Vals {
    // For creating new processes
    struct NewProcess {
      int priority;
      char file_name [256];
    } newProcess;

    // For IO calls
    char bc [256];
  } vals;

};


// Mode bit
const int MODE_NORMAL     = 0;
const int MODE_PRIVILEGED = 1;

// States
const int STATE_READY   = 0;
const int STATE_WAITING = 1;

// Return values
const int RET_SUCCESS     = 0;
const int RET_TERMINATED  = 1;
const int RET_NEW_PROCESS = 2;
const int RET_SYSCALL     = 3;
const int RET_ERROR       = -1;

class Process {
 private:
  int      pid, pc, vc, state, mode, priority, start_time, cycles_completed;
  char    code_loc [256];
  FILE* f;


 public:
  int fd;
  Process(int ipid, int priority, int istart_time, char icode_loc [256]);
  ProcessReturn run();
  int returnPid() { return pid; }
  int returnPriority() { return priority; }
  char* returnCodeLoc() { return code_loc; }
  char* getProcInfo() { char buf[1024]; sprintf(buf,"%d\t%d\t%s\t%d\t",pid,start_time,code_loc,cycles_completed); return buf;}
  void close();
};

#endif
